﻿#define _CRT_SECURE_NO_WARNINGS 1
// CMainDlg.cpp: 实现文件
//

#include "CMainDlg.h"
#include "afxdialogex.h"
#include "resource.h"


// CMainDlg 对话框

IMPLEMENT_DYNAMIC(CMainDlg, CDialogEx)

CMainDlg::CMainDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_MAIN_DLG, pParent)
{

}

CMainDlg::~CMainDlg()
{
}

void CMainDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


// 消息映射的桥梁
BEGIN_MESSAGE_MAP(CMainDlg, CDialogEx)
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()


// CMainDlg 消息处理程序


void CMainDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	//WCHAR s[256];
	//_stprintf(s, L"x = %d, y = %d", point.x, point.y);
	//_stprintf_s(s, _countof(s), L"x = %d, y = %d", point.x, point.y);

	CString str;
	str.Format(L"x = %d y = %d", point.x, point.y);

	if (MK_CONTROL & nFlags)
		str += L" - Ctrl键按下";
	if (MK_LBUTTON & nFlags)
		str += L" - 左键按下";
	if (MK_RBUTTON & nFlags)
		str += L" - 右键按下";
	if (MK_SHIFT & nFlags)
		str += L" - Shift按下";

	this->SetWindowText(str);

	CDialogEx::OnMouseMove(nFlags, point);
}


void CMainDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
	CString str;
	str.Format(L"x = %d, y = %d", point.x, point.y);
	//this->MessageBox(str, L"点击");
	CDialogEx::OnLButtonDown(nFlags, point);
}
